﻿using ChestPainCenterSystem.Areas.ChestPainCenter.Models;
using ChestPainCenterSystem.Code.Bll;
using ChestPainCenterSystem.Core;
using ChestPainCenterSystem.Utils;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ChestPainCenterSystem.Areas.ChestPainCenter.Controllers
{
    public class AppCaseConfigController : BaseController
    {
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult GetData(string Id = null)
        {
            OperateResult resultInfo = AppCaseConfigManager.GetData(Id);
            var res = new { Rows = resultInfo.Body };
            return JsonDate(res);
        }

        public ActionResult AddOrEdit(string Id)
        {
            ViewBag.Id = Id;
            return View();
        }

        public ActionResult SaveData()
        {
            AppCaseConfig qp = new AppCaseConfig()
            {
                Id = WebUtils.GetString("Id"),
                Name = WebUtils.GetString("Name"),
                Type = WebUtils.GetString("Type"),
                TCId = WebUtils.GetString("TCId"),
                Table_Name = WebUtils.GetString("Table_Name"),
                Column_Name = WebUtils.GetString("Column_Name"),
                State = WebUtils.GetString("State"),
                User_Control = WebUtils.GetString("User_Control"),
                Other_Constraint = WebUtils.GetString("Other_Constraint"),
                Power_UserID = WebUtils.GetString("Power_UserID"),
                Control_Order = WebUtils.GetString("Control_Order"),
                User_Control_Father = WebUtils.GetString("User_Control_Father"),
                Control_Label = WebUtils.GetString("Control_Label")
            };
            OperateResult result = AppCaseConfigManager.SaveData(qp);
            return Content(result.Body.ToString());
        }
        public ActionResult UpdateStatus()
        {
            string QualityPointTitle = WebUtils.GetString("QualityPointTitle");
            string id = WebUtils.GetString("Id");
            string Status = WebUtils.GetString("Status");
            OperateResult result = AppCaseConfigManager.UpdateStatus(id, Status);
            return Content(result.Body.ToString());
        }
    }
}
